package controller;

import pojo.Goods;
import pojo.Page;
import service.GoodsService;
import service.impl.GoodsServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/page")
public class GoodsController extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        获取页数
        String currentPage = req.getParameter("currentPage");
        GoodsService service = new GoodsServiceImpl();
        Page<Goods> page = service.findPage(Integer.parseInt(currentPage), 10);
//        保存域对象转发
        req.setAttribute("page", page);
        resp.sendRedirect("/goods/listshow.jsp'");
    }
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }
}
